/****************************************************************
 *
 *  Add some comments here
 * 
 * 
 * 
 * 
 ***************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using Wicresoft.SMS.Send.OmsService;

namespace Wicresoft.SMS.Send
{
    class Logger
    {
        private static OMSService oms;
        private static string pruductname = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString() + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
        private static string currentuser = ConfigManage.UserName;

        private static void WriteLog(string type, string msg)
        {
            try
            {
                if (oms == null)
                {
                    oms = new OMSService();                    
                }
                oms.Url = ConfigManage.ProviderUrl;
                if (oms.Url == "")
                    return;
                oms.WriteLog(DateTime.Now, pruductname, type, msg, ConfigManage.UserName);
            }
            catch (Exception)
            {
                
            }
            
        }


        public static void Exception(string msg)
        {
            WriteLog("Exception", msg);
        }

        public static void Exception(string msg, Exception ex)
        {
            WriteLog("Exception", msg + " ex:" + ex.ToString());
        }

        public static void Debug(string msg)
        {
            WriteLog("Debug", msg);    
        }

        public static void Info(string msg)
        {
            WriteLog("Info", msg);    
        }
    }
}
